package com.nba.common.security;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.springframework.web.multipart.MultipartException;
/**
 * MultipartParsingResult 内部类 反问不到所以重写
 * 
 * 
 */
public class CommonsMultipartResolver extends org.springframework.web.multipart.commons.CommonsMultipartResolver {

	public static 	String  MULTIPART_FILES = "MULTIPART_FILES";
	
	public static 	String  MULTIPART_PARAMETER_CONTENT_TYPES = "MULTIPART_PARAMETER_CONTENT_TYPES";
	
	public static 	String  MULTIPART_PARAMETERS = "MULTIPART_PARAMETERS";
	
	public CommonsMultipartResolver() {
		super();
	}
	public CommonsMultipartResolver(ServletContext servletContext){
		super(servletContext);
	}
	
	@Override
	protected MultipartParsingResult parseRequest(HttpServletRequest request) throws MultipartException {

		return super.parseRequest(request);
	}
	
	public Map<String,Object> getMultipartParsingResult(HttpServletRequest request){
		
		Map<String,Object> _result =  new HashMap<String,Object>();
		
		MultipartParsingResult result = this.parseRequest(request);
		
		_result.put(MULTIPART_FILES, result.getMultipartFiles());
		
		_result.put(MULTIPART_PARAMETER_CONTENT_TYPES, result.getMultipartParameterContentTypes());
		
		_result.put(MULTIPART_PARAMETERS, result.getMultipartParameters());
		
		return _result;
	}

}
